clear
%% PROBLEM
d = 2;
x_bound = repmat([-6,6],[d,1]);
OptSet.sol = [3,2;
    -2.805118,3.131312;
    -3.779310,-3.283186;
    3.584428,-1.848126];
OptSet.fval = 0;
OptSet.radius = 0.1;
precision_init = 0.4; % 3.848
MaximalBudget = 50000;
precision = [0.074, 0.024, 0.0074, 0.0024];

epsilon = [0.1,0.01,0.001,0.0001];

%% problem
Problem.Dimension = d; % the dimension of the decision variable
Problem.LowerBound = x_bound(:,1)'; % the lower bound of the decision variable
Problem.UpperBound = x_bound(:,2)'; % the upper bound of the decision variable
Problem.ObjFunc = @ObjValue;  % the objective function
%% ALGORITHM
Algorithm.PopulationSize = 80;  % the population size of the ga
Algorithm.F = 0.5;  % the mutation factor of the differential evolution
Algorithm.CR = 0.9;  % crossover index of the differential evolution
Algorithm.T = 40; % 80 for high dimension  % the threshold of the number of generations that solutions are not improved
Algorithm.MaxFEs = MaximalBudget; % the maximal budget

rep = 2;
TotalBudget = zeros(rep,length(epsilon));
TotalGeneration = zeros(rep,length(epsilon));
OptNoFound = zeros(rep,length(epsilon));
Times = zeros(rep,length(epsilon));
%%
for i=1:rep
    for iepsilon = 3%1:length(epsilon)
    OptSet.epsilon = epsilon(iepsilon);
    
        disp(['epsilon: ',num2str(epsilon(iepsilon)),', replication: ',num2str(i),'.'])
        tic
        [~, EvaluationNum, GenerationNum, OptSetRemain] = dsde_test(Problem, Algorithm, OptSet);
        Times(i,iepsilon) = toc;
        disp(['time used: ',num2str(Times(i,iepsilon)),'.'])
        TotalBudget(i,iepsilon) = EvaluationNum;
        OptNoFound(i,iepsilon) = size(OptSetRemain,1);
        TotalGeneration(i,iepsilon) = GenerationNum;
    end
end
%%
% save('EqualMinima.mat')

